forked from swiftlang/swift
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 29
 
Swift Runtime on WebAssembly #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
            MaxDesiatov
  merged 8 commits into
  swiftwasm:swiftwasm
from
kateinoigakukun:katei/wasm-runtime
  
      
      
   
  Nov 8, 2019 
      
    
                
     Merged
            
            Swift Runtime on WebAssembly #11
                    MaxDesiatov
  merged 8 commits into
  swiftwasm:swiftwasm
from
kateinoigakukun:katei/wasm-runtime
  
      
      
   
  Nov 8, 2019 
              
            Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    ImageInspectionShared was built only if host OS is Linux. But it's necessary when primary sdk is WASM.
Specify ar binary through extra-cmake-options
Because WASM doesn't support relative pointer, compiler emit direct address instead of offset from current address.
              
                    MaxDesiatov
  
              
              approved these changes
              
                  
                    Nov 8, 2019 
                  
              
              
            
            
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems legit 👍
    
  MaxDesiatov 
      pushed a commit
      that referenced
      this pull request
    
      Nov 14, 2019 
    
    
      
  
    
      
    
  
* [WASM] Build ImageInspectionShared even on macOS ImageInspectionShared was built only if host OS is Linux. But it's necessary when primary sdk is WASM. * [WASM] Use llvm-ar instead of ranlib on macOS Specify ar binary through extra-cmake-options * [WASM] Install llvm through HomeBrew to use llvm-ar * [WASM] Use llvm-ranlib instead of ranlib of Xcode * [WASM] Read offset as pointer when target is wasm Because WASM doesn't support relative pointer, compiler emit direct address instead of offset from current address. * [WASM] Copy SwiftRT-ELF.cpp into SwiftRT-WASM.cpp * [WASM] Emit empty swift5 sections if there aren't * [WASM] Remove swift_end and swift_start files
    
  MaxDesiatov 
      pushed a commit
      that referenced
      this pull request
    
      Dec 14, 2019 
    
    
      
  
    
      
    
  
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in #11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and #6 are merged, `print("Hello")` will work again! 🎉
    
  kateinoigakukun 
      added a commit
        to kateinoigakukun/swift
      that referenced
      this pull request
    
      Dec 14, 2019 
    
    
      
  
    
      
    
  
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
    
  kateinoigakukun 
      added a commit
      that referenced
      this pull request
    
      Dec 15, 2019 
    
    
      
  
    
      
    
  
* [WASM] Build ImageInspectionShared even on macOS ImageInspectionShared was built only if host OS is Linux. But it's necessary when primary sdk is WASM. * [WASM] Use llvm-ar instead of ranlib on macOS Specify ar binary through extra-cmake-options * [WASM] Install llvm through HomeBrew to use llvm-ar * [WASM] Use llvm-ranlib instead of ranlib of Xcode * [WASM] Read offset as pointer when target is wasm Because WASM doesn't support relative pointer, compiler emit direct address instead of offset from current address. * [WASM] Copy SwiftRT-ELF.cpp into SwiftRT-WASM.cpp * [WASM] Emit empty swift5 sections if there aren't * [WASM] Remove swift_end and swift_start files
    
  kateinoigakukun 
      added a commit
        to kateinoigakukun/swift
      that referenced
      this pull request
    
      Jan 11, 2020 
    
    
      
  
    
      
    
  
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
    
  kateinoigakukun 
      added a commit
      that referenced
      this pull request
    
      Jan 11, 2020 
    
    
      
  
    
      
    
  
* [WASM] Build ImageInspectionShared even on macOS ImageInspectionShared was built only if host OS is Linux. But it's necessary when primary sdk is WASM. * [WASM] Use llvm-ar instead of ranlib on macOS Specify ar binary through extra-cmake-options * [WASM] Install llvm through HomeBrew to use llvm-ar * [WASM] Use llvm-ranlib instead of ranlib of Xcode * [WASM] Read offset as pointer when target is wasm Because WASM doesn't support relative pointer, compiler emit direct address instead of offset from current address. * [WASM] Copy SwiftRT-ELF.cpp into SwiftRT-WASM.cpp * [WASM] Emit empty swift5 sections if there aren't * [WASM] Remove swift_end and swift_start files
    
  kateinoigakukun 
      added a commit
        to kateinoigakukun/swift
      that referenced
      this pull request
    
      Jan 24, 2020 
    
    
      
  
    
      
    
  
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
    
  kateinoigakukun 
      added a commit
        to kateinoigakukun/swift
      that referenced
      this pull request
    
      Jan 25, 2020 
    
    
      
  
    
      
    
  
This PR fixed my runtime implementation in SwiftRT. I've inserted dummy `char` data in each metadata sections to ensure that all start/stop symbols are generated in swiftwasm#11. But of cource this dummy data can be inserted anywhere in the section, so metadata sections were broken by this 1 byte. I changed to link these start/stop symbols weakly. Non-generated start/stop variables get to be uninitialized. So `stop-start` results 0 length, and runtime library can avoid to load empty section. After this and swiftwasm#6 are merged, `print("Hello")` will work again! 🎉
    
  MaxDesiatov 
      pushed a commit
      that referenced
      this pull request
    
      Jan 29, 2020 
    
    
      
  
    
      
    
  
* [WASM] Build ImageInspectionShared even on macOS ImageInspectionShared was built only if host OS is Linux. But it's necessary when primary sdk is WASM. * [WASM] Use llvm-ar instead of ranlib on macOS Specify ar binary through extra-cmake-options * [WASM] Install llvm through HomeBrew to use llvm-ar * [WASM] Use llvm-ranlib instead of ranlib of Xcode * [WASM] Read offset as pointer when target is wasm Because WASM doesn't support relative pointer, compiler emit direct address instead of offset from current address. * [WASM] Copy SwiftRT-ELF.cpp into SwiftRT-WASM.cpp * [WASM] Emit empty swift5 sections if there aren't * [WASM] Remove swift_end and swift_start files
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
This PR enables Swift's runtime support on WebAssembly.
What Changed
stdlib/public/runtime/SwiftRT-WASM.cpp
I changed to emit start and end address of sections prefixed with
swift5_such asswift5_protocol_conformances.wasm-ldsupports this feature since llvm/llvm-project@4bce63aTo handle the case when compiler doesn't emit the sections, creates dummy symbol located in the section.
lib/IRGen/MetadataRequest.cpp
__swift_instantiateConcreteTypeFromMangledNamewas designed to use relative pointer, so I changed to use absolute pointer only when WebAssembly.Misc